package org.feiyy.controller;

import org.feiyy.common.entity.SysUserEntity;
import org.feiyy.common.entity.SysUserTokenEntity;
import org.feiyy.service.ShiroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

@RestController
@RequestMapping("/sys/shiro")
public class ShiroController {

    @Autowired
    private ShiroService shiroService;

    @ResponseBody
    @GetMapping("/getUserPermissions")
    public Set<String> getUserPermissions(@RequestParam Long userId) {
        return shiroService.getUserPermissions(userId);
    }

    @ResponseBody
    @GetMapping("/queryByToken")
    public SysUserTokenEntity queryByToken(@RequestParam String token) {
        return shiroService.queryByToken(token);
    }

    @ResponseBody
    @GetMapping("/queryUser")
    public SysUserEntity queryUser(@RequestParam Long userId) {
        return shiroService.queryUser(userId);
    }

}
